/**
 * Im群组管理 api js文件
 */

import request from "@/utils/request";

/**
 * 查询IM群组的分页数据
 * @param {*} params
 * @returns
 */
export function queryPages(params) {
  return request({
    url: process.env.VUE_APP_KSTB_ROUTE_PATH + "/yxpz/imGroup/pages",
    method: "get",
    params: params
  });
}

/**
 * 校验账号是否存在
 * @param {*} loginAccount
 * @returns
 */
export function hasExistByLoginAccount(loginAccount) {
  return request({
    url:
      process.env.VUE_APP_KSTB_ROUTE_PATH +
      `/yxpz/imGroup/hasExistByLoginAccount/${loginAccount}`,
    method: "post",
    headers: {
      "Content-Type": "application/json;charset=UTF-8"
    }
  });
}

/**
 * 保存或修改数据
 * @param {*} data
 */
export function saveOrUpdate(data) {
  return request({
    url: process.env.VUE_APP_KSTB_ROUTE_PATH + "/yxpz/imGroup/saveOrUpdate",
    method: "post",
    headers: {
      "Content-Type": "application/json;charset=UTF-8"
    },
    data: data
  });
}

/**
 * 根据ID查询群组数据
 * @param {*} id
 */
export function getById(id) {
  return request({
    url: process.env.VUE_APP_KSTB_ROUTE_PATH + `/yxpz/imGroup/getById/${id}`,
    method: "post",
    headers: {
      "Content-Type": "application/json;charset=UTF-8"
    }
  });
}
/**
 * 删除群组数据
 * @param {*} id
 * @returns
 */
export function deleteGroup(id) {
  return request({
    url:
      process.env.VUE_APP_KSTB_ROUTE_PATH + `/yxpz/imGroup/deleteGroup/${id}`,
    method: "post",
    headers: {
      "Content-Type": "application/json;charset=UTF-8"
    }
  });
}

/**
 * 查询IM用户树
 * @param {*} params
 * @returns
 */
export function getImUserTree(params) {
  return request({
    url: process.env.VUE_APP_KSTB_ROUTE_PATH + "/yxpz/imGroup/getImUserTree",
    method: "get",
    params: params
  });
}
